    package ch.bfh.fbi.mobiComp2013.sensornet.implementation;

import java.io.Serializable;

public class MessageHeader implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public final long timeStamp;
	public final String senderID;
	public final MessageType type;
	
	public MessageHeader(String senderID,MessageType type){
		this.timeStamp=System.currentTimeMillis();
		this.senderID=senderID;
		this.type=type;
	}
	
	public String getSenderID() {
		return senderID;
	}
	public long getTimeStamp() {
		return timeStamp;
	}
	public MessageType getType() {
		return type;
	}

	@Override
	public String toString() {
		return "MessageHeader [timeStamp=" + timeStamp + ", senderID="
				+ senderID + ", type=" + type + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + senderID.hashCode();
		result = prime * result + (int) (timeStamp ^ (timeStamp >>> 32));
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		MessageHeader other = (MessageHeader) obj;
		if (senderID.equals(other.senderID))
			return false;
		if (timeStamp != other.timeStamp)
			return false;
		if (type != other.type)
			return false;
		return true;
	}
	
	
	
}
